package com.ztjy.sys.biz.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ztjy.bean.Journal;
import com.ztjy.bean.LogParams;
import com.ztjy.sys.biz.SysLogBiz;
import com.ztjy.sys.dao.JournalDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 日志业务逻辑层
 */
@Service
public class SysLogBizImpl implements SysLogBiz{
    @Autowired
    private JournalDao journalDao;
    @Override
    public boolean save(Journal journal) {
        boolean flag=false;
        try {
            flag  = journalDao.insertSelective(journal);
        }catch (Exception e){
            flag=false;
            e.printStackTrace();
        }
        return flag;
    }

    @Override
    public PageInfo<Journal> findAllLogs(LogParams logParams, Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo,pageSize);
        List<Journal> journals = journalDao.selectAllJournal(logParams);
        PageInfo<Journal> pageInfo = new PageInfo<Journal>(journals);
        return pageInfo;
    }

    @Override
    public Journal detailsLogs(Integer jid) {
        Journal journal = journalDao.selectByPrimaryKey(jid);
        return journal;
    }

}
